package org.lex.net.log;

import org.lex.net.log.Log.Type;

public class EnhancedLog {
	private static final Object[] EMPTY = { "" };
	protected Log logger = null;
	protected Object source = null;

	public EnhancedLog(Log log) {
		this(log, null);
	}

	public EnhancedLog(Log logger, Object source) {
		this.logger = logger;
		this.source = source;
	}

	public void setSource(Object url) {
		this.source = url;
	}

	public Log getLog() {
		return this.logger;
	}

	public EnhancedLog send(Object message) {
		logger.send(source, message);
		return this;
	}

	public EnhancedLog error(Object message) {
		logger.error(source, message);
		return this;
	}

	public EnhancedLog misc(Object message) {
		logger.misc(source, message);
		return this;
	}

	public EnhancedLog reply(Object message) {
		logger.reply(source, String.valueOf(message));
		return this;
	}

	public EnhancedLog log(Type type, Object... msgs) {
		if (null == msgs || 0 == msgs.length)
			msgs = EMPTY;
		for (int i = 0; i < msgs.length; i++)
			logger.log(type, source, String.valueOf(msgs[i]));
		return this;
	}
}
